package com.bigshen.demo.annotation.configurecomponents.a0Configuration;

import com.bigshen.demo.project.entity.Person;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class MyTest {

    @Test
    public void test() {

        ApplicationContext applicationContext = new AnnotationConfigApplicationContext(MyConfig.class);

        // beanName默认为类名首字母小写
//        Person person = (Person) applicationContext.getBean("person");
        // beanName默认为方法名
//        Person person = (Person) applicationContext.getBean("getPerson");
        // 使用bean注解的value
        Person person = (Person) applicationContext.getBean("myPerson");
        System.out.println(person);

        Person person2 = applicationContext.getBean(Person.class);
        System.out.println(person2);

        System.out.println(person == person2);

    }

}
